﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
/// <summary>
///AddToUserFavorite 的摘要说明
/// </summary>
public class AddToUserFavorite
{


	public static bool AddToUser(int userId, int bookId)
	{
        SqlConnection sqlconn = new SqlConnection(ConfigurationManager.AppSettings["ConnectionString"]);
        SqlOperate sqloperate = new SqlOperate();

        string sqltest = "select * from TempStore where UserId='" + userId + "'";
        sqlconn.Open();
        SqlCommand sqlcom = new SqlCommand(sqltest, sqlconn);
        SqlDataReader read = sqlcom.ExecuteReader();
        read.Read();
        if (read.HasRows)
        {
            return false;                                                         //已经添加至收藏
        }
        string sqlstr = "insert into TempStore where UserId='" + userId + "'";
        sqloperate.DataCom(sqlstr);
        sqlconn.Close();
        return true;
	}
}
